package com.qyhl.webtv.module_live.teletext.nanbu;

import android.util.Log;

import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.common.CommonUtils;
import com.qyhl.webtv.commonlib.entity.civilized.PracticeBrandBean;
import com.qyhl.webtv.commonlib.entity.live.NanBuLiveTagBean;
import com.qyhl.webtv.module_live.common.LiveUrl;

import java.util.List;

public class NanBuLiveListModel implements NanBuLiveListContract.NanBuLiveListModel {
    private NanBuLiveListPresenter mPresenter;

    public NanBuLiveListModel(NanBuLiveListPresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getTagList() {
        EasyHttp.get(LiveUrl.GET_NANBU_LIVE_TAG)
                .params("isOperate", "0")
                .params("parentId","0")
                .params("siteId", CommonUtils.getInstance().getSite() + "")
                .execute(new SimpleCallBack<List<NanBuLiveTagBean>>() {
                    @Override
                    public void onError(ApiException e) {
                        if (e.getCode() == 202) {
                            mPresenter.setTagError("暂无任何标签！");
                        } else {
                            mPresenter.setTagError("请求出错，请重新获取！");
                        }
                    }

                    @Override
                    public void onSuccess(List<NanBuLiveTagBean> NanBuLiveTagBean) {
                        if (NanBuLiveTagBean != null && NanBuLiveTagBean.size() > 0) {
                            mPresenter.setTagList(NanBuLiveTagBean);
                        } else {
                            mPresenter.setTagError("暂无任何内容！");
                        }
                    }
                });
    }
}
